package com.anhry.app.safety.util;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * 2010-04-08
 * remark: 在线用户监听
 * author: anhry
 *
 */
public class OnlineUserListener implements HttpSessionListener {

	public void sessionCreated(HttpSessionEvent event) {
		OnlineUser u = new OnlineUser();
//		System.out.println("欢迎登陆系统");
		u.setName("---");
		u.setId(event.getSession().getId());
		event.getSession().setAttribute("currentUser",u);
		OnlineUsers.getInstance().addUser(u);
	}

	public void sessionDestroyed(HttpSessionEvent event) {
//		System.out.println("删除用户:"+event.getSession().getAttribute("currentUser"));
		OnlineUsers.getInstance().removeUser(event.getSession().getId());
	}
}
